<?php $this->load->view('admin/header'); ?>
<div class="main clear">
    <div class="tool">
        <a href="/index.php?d=admin&c=mine" >个人资料</a>
        <a href="/index.php?d=admin&c=mine&m=editpass">修改密码</a>
        <?php if($_COOKIE['username'] == 'admin'){echo '<a href="/index.php?d=admin&c=mine&m=adminlist">管理员列表</a><a href="/index.php?d=admin&c=mine&m=addadmin">增加管理员</a>';}?>

    </div>
    <?php if($op=='info'){?>
    <div class="table01">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td style="width: 150px;"><span>账号</span></td>
                <td>
                    <?php echo $userinfo['username']?>
                </td>
            </tr>
            <tr>
                <td><span>笔名</span></td>
                <td>
                    <?php echo $userinfo['nickname']?>
                </td>
            </tr>
            <tr>
                <td><span>头像</span></td>
                <td>
                    <div style="padding: 5px;"><img src="<?php echo $userinfo['photo']?>" width="100" height="100"/></div>
                </td>
            </tr>
            <tr>
                <td><span>qq</span></td>
                <td>
                    <?php echo $userinfo['qq']?>
                </td>
            </tr>
            <tr>
                <td><span>手机号</span></td>
                <td>
                    <?php echo $userinfo['phone']?>
                </td>
            </tr>
            <tr>
                <td><span>一句话介绍</span></td>
                <td>
                    <?php echo $userinfo['intro']?>
                </td>
            </tr>
        </table>
        <?php }else if($op=='editpass'){?>
        <form  id="article_form" method="post" action="/index.php?d=admin&c=mine&m=savepass" onsubmit="return check();">
            <div class="add_item" style="margin-top: 10px;">
                <label>旧密码：</label>
                <input type="text" value="" id="pass_old" name="pass_old" class="txt width500">
            </div>
            <div class="add_item" style="margin-top: 10px;">
                <label>新密码：</label>
                <input type="text" value="" id="pass_new" name="pass_new" class="txt width500">
            </div>
            <div class="add_item" style="margin-top: 10px;">
                <label>确认新密码：</label>
                <input type="text" value="" id="pass_new2" name="pass_new2" class="txt width500">
            </div>
            <div class="btn_box" style="text-align: left">
                <input type="hidden" value="<?php if(isset($username)){echo $username;}?>"  name="username" id="username"/>
                <input type="submit"  value="保存" />
            </div>
        </form>
            <script type="text/javascript">
                function check(){

                    var pass_old = $('#pass_old').val();
                    var pass_new = $('#pass_new').val();
                    var pass_new2 = $('#pass_new2').val();
                    if(pass_old.length<6){
                        alert('旧密码不能为空');
                        return false;
                    }
                    if(pass_new.length<6 || pass_new2.length<6){
                        alert('请输入六位以上的新密码');
                        return false;
                    }
                    if(pass_new2!==pass_new){
                        alert('两次密码输入不一致');
                        return false;
                    }
                    return true;
                }
            </script>
        <?php }else if($op=='addadmin'){?>
            <form  id="article_form" method="post" action="/index.php?d=admin&c=mine&m=saveadmin" onsubmit="return check_addadmin();">
                <div class="add_item" style="margin-top: 10px;">
                    <label>账号：</label>
                    <input type="text" value="" id="username" name="username" class="txt width500">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>密码：</label>
                    <input type="text" value="" id="password" name="password" class="txt width500">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>确认密码：</label>
                    <input type="text" value="" id="password2" name="password2" class="txt width500">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>笔名：</label>
                    <input type="text" value="" id="nickname" name="nickname" class="txt width500">
                </div>
                <div class="add_item">
                    <label>缩略图：</label>
                    <input type="text" value="<?php if(isset($info['photo'])){echo $info['photo'];}?>"  name="flash_pic" class="txt width500" id="photo">
                    <input type="hidden" id="h_pic">
                    <a onclick="showupwindow('photo')" href="javascript:;">上传</a>
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>qq：</label>
                    <input type="text" value="" id="qq" name="qq" class="txt width500">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>手机号：</label>
                    <input type="text" value="" id="phone" name="phone" class="txt width500">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>一句话介绍：</label>
                    <input type="text" value="" id="intro" name="intro" class="txt width500">
                </div>
                <div class="btn_box" style="text-align: left">

                    <input type="submit"  value="保存" />
                </div>
            </form>
            <script type="text/javascript">
                function showupwindow(id){
                    $('#h_pic').val(id);
                    $('body').append('<div style="width: 349px; height: 220px; margin-left: -175px; margin-top: -110px; top: 355px;" class="xheModal" id="div_up"><div class="xheModalTitle"><span title="关闭 (Esc)" class="xheModalClose" onclick="close_up()"></span>上传文件</div><div class="xheModalContent" style="height: 191px;"><iframe frameborder="0" style="width: 100%; height: 100%;" src="/static/xheditor/xheditor_plugins/multiupload/multiupload.html?watermark=0"></iframe></div></div>');
                    $('#div_up').css('top', $(document).scrollTop() + (window.screen.availHeight / 2 - 80));
                }

                function close_up(){
                    $('#div_up').remove();
                }
                function check_addadmin(){
                    var username = $('#username').val();
                    var password = $('#password').val();
                    var password2 = $('#password2').val();
                    if(username.length<1){
                        alert('用户名不能为空');
                        return false;
                    }
                    if(password.length<6 || password2.length<6){
                        alert('请输入六位以上的密码');
                        return false;
                    }
                    if(password!==password2){
                        alert('两次密码输入不一致');
                        return false;
                    }
                    return true;
                }
            </script>
        <?php }else if($op=='adminlist'){?>
        <div class="table01">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th style="width: 100px;"><span>账号</span></th>
                    <th style="width: 100px;"><span>笔名</span></th>
                    <th style="width: 50px;"><span>状态</span></th>
                    <th ><span>操作</span></th>
                </tr>
                <?php if(isset($admin_list) && !empty($admin_list)){?>
                    <?php foreach($admin_list as $v){?>
                        <?php if($v['username'] != 'admin'){?>
                        <tr>
                            <td style="width: 100px;"><span><?php echo $v['username'];?></span></td>
                            <td style="width: 100px;"><span><?php echo $v['nickname'];?></span></td>
                            <td style="width: 100px;"><span><?php echo $dis_arr[$v['disabled']];?></span></td>
                            <td>
                                <?php if($v['disabled'] == 0){?><a href="/index.php?d=admin&c=mine&m=changdisable&flag=1&userid=<?php echo $v['userid'];?>">禁用</a>|<?php }else{?><a href="/index.php?d=admin&c=mine&m=changdisable&flag=0&userid=<?php echo $v['userid'];?>">启用</a>|<?php }?>
                                <a href="/index.php?d=admin&c=mine&m=changpass_other&username=<?php echo $v['username'];?>">修改密码</a>
                            </td>
                        </tr>
                        <?php }?>
                    <?php }?>
                <?php }?>
            </table>
            </div>
        <?php }else if($op=='changpass_other'){?>
            <form  id="article_form" method="post" action="/index.php?d=admin&c=mine&m=savepass_other" onsubmit="return check_pass_other();">
                <div class="add_item" style="margin-top: 10px;">
                    <label>账号：</label>
                    <input type="text" value="<?php echo $username;?>" id="username" name="pass_old" class="txt width500" disabled>
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>新密码：</label>
                    <input type="text" value="" id="pass_new" name="pass_new" class="txt width500">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>确认新密码：</label>
                    <input type="text" value="" id="pass_new2" name="pass_new2" class="txt width500">
                </div>
                <div class="btn_box" style="text-align: left">
                    <input type="hidden" value="<?php if(isset($username)){echo $username;}?>"  name="username" id="username"/>
                    <input type="submit"  value="保存" />
                </div>
            </form>
            <script type="text/javascript">
                function check_pass_other(){

                    var pass_new = $('#pass_new').val();
                    var pass_new2 = $('#pass_new2').val();

                    if(pass_new.length<6 || pass_new2.length<6){
                        alert('请输入六位以上的新密码');
                        return false;
                    }
                    if(pass_new2!==pass_new){
                        alert('两次密码输入不一致');
                        return false;
                    }
                    return true;
                }
            </script>
        <?php }?>
    </div>
</div>

<?php $this->load->view('admin/footer'); ?>